Quick Start
Preprocessing is automatically configured when loading models:Preprocessing Configuration
PreprocessCfg
ThePreprocessCfg dataclass defines all preprocessing parameters:
int | Tuple[int, int]
default:"224"
Target image size. Can be int for square images or (height, width) tuple.
Tuple[float, float, float]
RGB mean values for normalization. Defaults to OpenAI CLIP values:
(0.48145466, 0.4578275, 0.40821073)Tuple[float, float, float]
RGB standard deviation for normalization. Defaults to:
(0.26862954, 0.26130258, 0.27577711)str
default:"bicubic"
Resize interpolation method: ‘bicubic’, ‘bilinear’, or ‘nearest’
str
default:"shortest"
Resize strategy:
'shortest': Resize shortest edge, then center crop'longest': Resize longest edge, then center crop/pad'squash': Direct resize to target size (may distort)
Creating Transforms
image_transform_v2()
Create preprocessing transforms from configuration:Resize Modes
Shortest Edge (Default)
Resize shortest edge to target, then center crop:This is the default for most CLIP models and preserves aspect ratio before cropping.
Longest Edge
Resize longest edge, pad to square:Squash Mode
Direct resize (may distort aspect ratio):Augmentation Configuration
AugmentationCfg
Configure training data augmentation:Tuple[float, float]
default:"(0.9, 1.0)"
Scale range for RandomResizedCrop. Values are fractions of original image size.
Tuple[float, float]
Aspect ratio range for RandomResizedCrop
Tuple[float, ...]
Color jitter parameters: (brightness, contrast, saturation, hue)
float
Probability of applying color jitter (0.0 to 1.0)
float
Probability of converting to grayscale (0.0 to 1.0)
bool
default:"False"
Use timm library’s augmentation (RandAugment, etc.)
